<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../common/tagInclude.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
	<base href="${basePath}" />
	<title>栏目信息列表</title>
	<META http-equiv="content-type" content="text/html; charset=UTF-8">
	<LINK href="${basePath}styleAdmin/css/portalinabox.css" type="text/css" rel="stylesheet">		
	<meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
   <meta http-equiv="expires" content="0">
	<script type="text/javascript" src="${basePath}styleAdmin/js/prototype-1.6.0.3.js"></script>
	<script type="text/javascript">
		function edit(id){
			window.location = '${basePath}admin/channel/showUpdate?channelId='+id;
		}
		function del(id){
			if(!confirm('删除栏目的同时其下所有文章将归为"未知分类"!请慎重! \r\n\r\n                确认删除')) return;
			window.location = '${basePath}admin/channel/delete?channelId='+id;
		}
		function doQuery(){
			var url = "${basePath}admin/channel/list"; 
			document.myform.action = url ;
			document.myform.submit();
		}
	  function saveSort(){
	  	var checkIds = "";
	  	var boxes = document.getElementsByName("checkId");
	  	for (var i = 0; i < boxes.length; i++){  
	  		if (boxes[i].checked){  
	  			checkIds += "," + boxes[i].value;
	  		}
	  	}
	  	checkIds = checkIds.substring(1);
	  	var url = "${basePath}admin/channel/sort?checkId=" + checkIds ;
		window.location = url ;	  	
	  }
</script>
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">
<form action="" method="get" name="myform">
<%@ include file="../common/navigate.jsp" %>
<input type="hidden" name="channelParentId" id="channelParentId" value='${channelParentId}' />
<table width="96%" border="0" align="center" cellpadding="0" style="margin-top:5px;" cellspacing="0">
	<tr>
		<td valign="top">
			<!-- 搜索栏 -->
			<table width="100%" border="1" class="mainFunctionTable"  cellpadding="0" cellspacing="1">
				<tr height="25" class="pLabel">
			   		<td class="td_nwarpstyle">&nbsp;&nbsp;栏目信息列表&nbsp;&nbsp;
			   		<c:choose>
			   			<c:when test="${languageId > 0 && channelParentId > 0 }">父节点[${clObj.channelName}]</c:when>
			   			<c:otherwise>根节点</c:otherwise>
			   		</c:choose>
					</td>
			 	</tr>
				<tr>
			   		<td width="100%" height="25">
			   			<table width="100%" border="0" cellspacing="1">
			     			<tr>
			       				<td>&nbsp;&nbsp;所属语种&nbsp;&nbsp;<select name="languageId" id="languageId">
				         				<option value="">请选择</option>
										<c:forEach items="${languageInfoList }" var="languageInfo">
				         					<option value="${languageInfo.id}" <c:if test="${languageInfo.id == languageId}">selected</c:if>>${languageInfo.name }</option>
				         				</c:forEach>
			         				</select>
			       				</td>
			       				<td align="right">
			       					<a href="javascript:doQuery();"><img src="${basePath}styleAdmin/images/button/query.gif" border="0"/></a>
			       					&nbsp;&nbsp;&nbsp;&nbsp;<a href="${basePath}admin/channel/showInsert?channelParentId=${channelParentId}&languageId=${languageId}" id="lnkAdd"><img src="${basePath}styleAdmin/images/button/addNew.gif" border="0"></a>
			        			</td>
			     			</tr>
			    		</table>
			    	</td>
			   </tr>
				<tr >
			   		<td width="100%" height="25" align="center" name="submit" id="submit" style="display:none">
			    		<input type="button" value="保存排序" onclick="javascript:saveSort();">&nbsp;&nbsp;<font color="red">点击排序之后，记得"保存"</font>
			    	</td>
			   </tr>
			 </table>
		  </td>
	  </tr>
	  <tr>
	    <td>
			<table width=100% border=1 class="mainFunctionTable"  cellpadding="0" cellspacing="1" id="table_channel">
				<tr height=25 class="pLabel"  align="center">
					<td width="20%" class="td_nwarpstyle" >栏目名称</td>
					<!-- <td class="td_nwarpstyle" >栏目描述</td> -->
					<td width="10%" class="td_nwarpstyle">语种</td>
					<td width="10%" class="td_nwarpstyle">展现形式</td>
					<td width="10%" class="td_nwarpstyle">栏目图片</td>
					<%//if(languageId > 0 && channelParentId > 0 ){%>
					<td width="15%" class="td_nwarpstyle" align="center" >排序</td>
					<td width="10%" class="td_nwarpstyle" align="center" >操作</td>
					<%//} %>
				</tr>
			</table>
			<table width=100% border=1 class="mainFunctionTable"  cellpadding="0" cellspacing="1" id="table_channel">
				<c:forEach items="${channelInfoList}" var="channelInfo" varStatus="status">
   					<c:choose>
   						<c:when test="${status.index % 2 == 0 }"><c:set var="css" value="c1" /></c:when>
   						<c:otherwise><c:set var="css" value="c2" /></c:otherwise>
   					</c:choose>
						<tr class="${css}">
						<td width="20%" height="25">
							<c:choose>
					   			<c:when test="${channelInfo.hasChild == 1}">
					   				<a href='${basePath}admin/channel/list?channelParentId=${channelInfo.channelId}&languageId=${channelInfo.languageId}' title="点击查看子分类">${channelInfo.channelName}</a>
					   			</c:when>
					   			<c:otherwise>${channelInfo.channelName}</c:otherwise>
				   			</c:choose>
						<div style="display:none">
							<input type="checkbox" name="checkId" id="checkId" value="${channelInfo.channelId}" checked="checked" />
							<input type="checkbox" name="checkSort" id="checkSort" value='${status.index + 1 }' checked="checked"/>
						</div>
						</td>
						<!-- <td><%//=cl.getChannelDesc() %></td> -->
						<td width="10%" align="center">${languageMap[channelInfo.languageId]}</td>
						<td width="10%" align="center">
							<c:choose>
					   			<c:when test="${channelInfo.showType == 1}">列表展现</c:when>
					   			<c:otherwise>内容展现</c:otherwise>
				   			</c:choose>
						</td>
						<td width="10%" align="center">
							<c:choose>
					   			<c:when test="${not empty channelInfo.channelImage}"><a href="${channelInfo.channelImage}" target="_blank">查看</a></c:when>
					   			<c:otherwise>暂无</c:otherwise>
				   			</c:choose>
						</td>
						<%//if(languageId > 0 && channelParentId > 0 ){%>
						<td width="15%" align="center">
							<a href="javascript:void(0)" onclick="moveUp(this)"><img src="${basePath}styleAdmin/images/up.gif" border="0" title="上移"></a>&nbsp;&nbsp;
							<a href="javascript:void(0)" onclick="moveDown(this)"><img src="${basePath}styleAdmin/images/down.gif" border="0" title="下移"></a>
						</td>
						<td width="10%" align=center>
							<a href="javascript:edit(${channelInfo.channelId});"><img src="${basePath}styleAdmin/images/edit.gif" border="0" title="编辑"/></a>
							&nbsp;&nbsp;
							<a href="javascript:del(${channelInfo.channelId});"><img src="${basePath}styleAdmin/images/delete.gif" border="0" title="删除"/></a>
						</td>
						<%//} %>
					</tr>
				</c:forEach>
	  		</table>
		 </td>
	   </tr>
		<tr>
		  <td height=25>
		   	<c:set var="pageURL" value="${basePath}admin/channel/list?languageId=${languageId}&channelParentId=${channelParentId}&"/>
			<%@include file="../common/page.jsp"%>
		  </td>
	  </tr>
</table>
</form>
<script language="JavaScript" type="text/javascript">   
<!--    
function cleanWhitespace(element) {    
 //遍历element的子结点    
 for (var i = 0; i < element.childNodes.length; i++) {    
  var node = element.childNodes[i];    
  //判断是否是空白文本结点，如果是，则删除该结点    
  if (node.nodeType == 3 && !/\S/.test(node.nodeValue))     
  node.parentNode.removeChild(node);    
 }    
}    
//获得表格对象    
var _table=document.getElementById("table_channel");    
cleanWhitespace(_table);    
//使表格行上移，接收参数为链接对象    
function moveUp(_a){ 
   if(document.getElementById("submit").style.display == "none"){
  	document.getElementById("submit").style.display = "block" ;  
  }  
 //通过链接对象获取表格行的引用    
 var _row=_a.parentNode.parentNode;    
 //如果不是第一行，则与上一行交换顺序    
 if(_row.previousSibling)swapNode(_row,_row.previousSibling);    
}    
//使表格行下移，接收参数为链接对象    
function moveDown(_a){
  if(document.getElementById("submit").style.display == "none"){
  	document.getElementById("submit").style.display = "block" ;
  }  
 //通过链接对象获取表格行的引用    
 var _row=_a.parentNode.parentNode;    
 //如果不是最后一行，则与下一行交换顺序    
 if(_row.nextSibling)swapNode(_row,_row.nextSibling);    
}    
//定义通用的函数交换两个结点的位置    
function swapNode(node1,node2){    
 //获取父结点    
 var _parent=node1.parentNode;    
 //获取两个结点的相对位置    
 var _t1=node1.nextSibling;    
 var _t2=node2.nextSibling;    
 //将node2插入到原来node1的位置    
 if(_t1)_parent.insertBefore(node2,_t1);    
 else _parent.appendChild(node2);    
 //将node1插入到原来node2的位置    
 if(_t2)_parent.insertBefore(node1,_t2);    
 else _parent.appendChild(node1);    
}    
//-->   
</script> 
</body>
</HTML>